Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Add classes for array and slice literals#175

Merged
owen-mc merged 3 commits intogithub:masterfrom
owen-mc:array-slice-literal
Jun 12, 2020
Merged

Add classes for array and slice literals#175
owen-mc merged 3 commits intogithub:masterfrom
owen-mc:array-slice-literal

Conversation

@owen-mc
Copy link
Copy Markdown
Contributor

@owen-mc owen-mc commented Jun 11, 2020

No description provided.

@owen-mc owen-mc requested a review from a team June 11, 2020 18:57
Comment thread ql/src/semmle/go/Expr.qll Outdated
class ArrayOrSliceLit extends CompositeLit {
Type type;

ArrayOrSliceLit() { getType() instanceof ArrayType or getType() instanceof SliceType }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you perhaps mean to bind the field type here?

Suggested change
ArrayOrSliceLit() { getType() instanceof ArrayType or getType() instanceof SliceType }
ArrayOrSliceLit() { type = getType() and (type instanceof ArrayType or type instanceof SliceType) }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course you can also just remove the field altogether and leave the characteristic predicates as they are.

Comment thread ql/src/semmle/go/Expr.qll Outdated
* ```
*/
class ArrayLit extends ArrayOrSliceLit {
ArrayLit() { getType() instanceof ArrayType }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you bind type as suggested above, you can now do

Suggested change
ArrayLit() { getType() instanceof ArrayType }
override ArrayType type;

Comment thread ql/src/semmle/go/Expr.qll Outdated
* ```
*/
class SliceLit extends CompositeLit {
SliceLit() { getType() instanceof SliceType }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SliceLit() { getType() instanceof SliceType }
override SliceType type;

@owen-mc owen-mc force-pushed the array-slice-literal branch from 9aec22c to 32e7b93 Compare June 12, 2020 04:20
@owen-mc owen-mc force-pushed the array-slice-literal branch from bbf5a21 to e6217d9 Compare June 12, 2020 10:24
@owen-mc
Copy link
Copy Markdown
Contributor Author

owen-mc commented Jun 12, 2020

I've added a commit to update the strings for map and struct literals as well

@owen-mc owen-mc merged commit 282b8cb into github:master Jun 12, 2020
@owen-mc owen-mc deleted the array-slice-literal branch June 12, 2020 11:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants